package com.wangijun.yuan.web.model.dto;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class PageParam<T> {
    @Schema(description = "每几页")
    private Integer pageNum;
    @Schema(description = "每页大小")
    private Integer pageSize;

    /**
     * 功能描述: 获取分页信息
     *
     * @author wlf 2024/6/18 20:23
     */
    public Page<T> page() {
        if (this.pageNum == null || this.pageSize == null) {
            this.pageNum = 1;
            this.pageSize = 20;
        }
        if (this.pageSize > 100) {
            this.pageSize = 100;
        }
        return Page.of(this.pageNum, this.pageSize);
    }
}
